﻿#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;

class Solution {
public:
    bool find132pattern(vector<int>& nums) {
        int max_2 = -0x7f7f7f7f;
        stack<int> candidate_2;
        candidate_2.push(nums[nums.size() - 1]);
        for (int i = nums.size() - 2; i >= 0; i--) {
            int c = nums[i];
            if (c < max_2) return true;
            while (!candidate_2.empty() && candidate_2.top() < c) {
                max_2 = max(max_2, candidate_2.top());
                candidate_2.pop();
            }
            candidate_2.push(c);
        }
        return false;
    }
};

Solution solution;

int main() {
    vector<int> nums = { -1,3,2,0 };
    cout << solution.find132pattern(nums) << endl;
    return 0;
}